import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:oktoast/oktoast.dart';
import 'package:flutter_acrylic/flutter_acrylic.dart';
import 'com.comm/page/home.dart';

void main() async {
  // WidgetsFlutterBinding.ensureInitialized();
  // await Window.initialize();
  // await Window.setEffect(
  //   effect: WindowEffect.transparent, // 设置透明效果
  //   color: Colors.transparent, // 背景色透明
  // );
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return OKToast(
        child: MaterialApp(
      theme: ThemeData(
        // 设置 Scaffold 的背景颜色为淡蓝色
        scaffoldBackgroundColor: Colors.white,
        dialogTheme:DialogThemeData(
          backgroundColor: Colors.white,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(8),
          ),
        ),
        // primarySwatch: Colors.green,
      ),
      title: '多语言翻译',
      //国际化配置
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate, //iOS
      ],

      supportedLocales: [
        const Locale('zh', 'CN'),
        const Locale('en', 'US'),
      ],
      // theme: ThemeData(
      //    primarySwatch: Colors.green,
      // ),
      home: BottomNavigationBarHome(),
    ));
  }
}

class BottomNavigationBarHome extends StatefulWidget {
  @override
  _BottomNavigationBarHomeState createState() =>
      _BottomNavigationBarHomeState();
}

class _BottomNavigationBarHomeState extends State<BottomNavigationBarHome> {
  int _selectedIndex = 0;

  static List<Widget> _widgetOptions = <Widget>[
    Home(),
    Text('敬请期待'),
  ];

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
          child: Row(
        children: [
          //导航栏
          NavigationRail(
            indicatorColor: Colors.blue.shade50,
            backgroundColor: Colors.white,
            selectedIndex: _selectedIndex,
            onDestinationSelected: _onItemTapped,
            labelType: NavigationRailLabelType.all,
            destinations: const [
              NavigationRailDestination(
                icon: Icon(Icons.home),
                label: Text('首页'),
              ),
              NavigationRailDestination(
                icon: Icon(Icons.search),
                label: Text('工具'),
              ),
            ],
          ),
          const VerticalDivider(thickness: 1, width: 0.5),
          Expanded(
            child: Center(
              child: _widgetOptions.elementAt(_selectedIndex),
            ),
          ),
        ],
      )),
    );
  }
}
